package sel.me.spring.beans.factory;

import java.util.Date;

import org.springframework.beans.factory.FactoryBean;
import org.springframework.stereotype.Component;

@Component
public class SimpleFactoryBean implements FactoryBean<Object> {  
    private boolean flag; 
    
    private String value;; 
  
    public Object getObject() throws Exception {  
        if (flag) {  
            //return new Date();
        	return new Object();
        }  
        return new String("Hello FactoryBean");  
    }  
  
    @SuppressWarnings("unchecked")  
    public Class getObjectType() {  
        return flag ? Date.class : String.class;  
    }  
  
    public boolean isSingleton() {  
        return false;  
    }  
  
    public void setFlag(boolean flag) {  
        this.flag = flag;  
    }

	public String getValue() {
		return value;
	}

	public void setValue(String value) {
		this.value = value;
	}  
}  
